package com.twu.biblioteca.ui;

import com.twu.biblioteca.domain.Book;
import com.twu.biblioteca.domain.Repository;
import com.twu.biblioteca.io.IO;

import java.util.Collection;

public class ViewBookListMenuItemHandler implements MenuItemHandler {

    private Repository<Book> bookRepository;
    private IO io;

    public ViewBookListMenuItemHandler(Repository<Book> bookRepository, IO io) {
        this.bookRepository = bookRepository;
        this.io = io;
    }

    @Override
    public void handle() {
        Collection<Book> books = bookRepository.getAll();
        for (Book book: books) {
            io.writeOutput(book);
        }
    }
}
